// pages/index1/index1.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    checks: [
      
    ],
    arr:'',
    arrname: '',
  },
  clicks: function (e) {
    let that = this;
    let index = e.currentTarget.dataset.index;
    let arrs = that.data.checks;
    if (arrs[index].checked == false) {
      for (var s = 0; s < arrs.length; s++) {
        arrs[s].checked = false;
      }
      arrs[index].checked = true;
      that.setData({ arr: arrs[index].id, arrname: arrs[index].name})
    } else {
      arrs[index].checked = false;
    }
    this.setData({
      checks: arrs
    })
    // console.log(arrs)
  },
  gojh2:function(){
    let that = this;
    // console.log(that.data.arr)
    wx.navigateTo({
      url: '../index2/index2?pid=' + that.data.arr + "&name=" + that.data.arrname
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    app.post("/category/org_type","get",{}).then(res =>{
      res.forEach(function(v,i){
        res[i].checked = false;
        res[i].value = res[i].id;
      })
      that.setData({ checks:res})
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})